package com.za.wbw.service.wap.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.za.wbw.dao.wap.ShopDao;
import com.za.wbw.service.wap.ShopService;
import com.za.wbw.model.wap.ShopInfo;
import com.za.wbw.model.wap.vo.ProductSellVo;
import com.za.wbw.model.wap.vo.ShopInfoVo;
import com.za.wbw.model.wap.vo.ShopListVo;

public class ShopServiceImpl implements ShopService {
	
	private ShopDao shopDao;

	public ShopDao getShopDao() {
		return shopDao;
	}

	public void setShopDao(ShopDao shopDao) {
		this.shopDao = shopDao;
	}
	
	// 查询商店信息
	public ShopInfoVo queryShopInfoById(int shopId) throws Exception{
		ShopInfo info = this.getShopDao().queryShopInfoById(shopId);
		ShopInfoVo vo = new ShopInfoVo();
		vo.setShopId(info.getShopId());
		vo.setShopName(info.getShopName());
		vo.setTelephone(info.getTelephone());
		vo.setShopBrief(info.getShopBrief());
		vo.setAddress(info.getStreetDoor());
		vo.setPosX(info.getPosX());
		vo.setPoxY(info.getPosY());
		return vo;
	}
	// 查询商品
	public List<ShopListVo> queryShopList(int start, int cityId, int typeId, int posX, int posY, int radius, int sort) throws Exception{
		List<ShopInfo> list = this.getShopDao().queryShopList(start, cityId, typeId, posX, posY, radius, sort);
		List<ShopListVo> voList = new ArrayList<ShopListVo>();
		for (ShopInfo info : list) {
			ShopListVo vo = new ShopListVo();
			vo.setShopId(info.getShopId());
			vo.setShopName(info.getShopName());
			vo.setShopLabelName(info.getLabelName());
			vo.setAddress(info.getProviceName()+info.getCityName()+info.getAreaName()+info.getStreetDoor());
			vo.setPosX(info.getPosX());
			vo.setPoxY(info.getPosY());
			voList.add(vo);
		}
		return voList;
	}
	// 查询商店总数
	public int queryShopCount(int cityId, int typeId, int posX, int posY, int radius, int sort) throws Exception{
		return this.getShopDao().queryShopCount(cityId, typeId, posX, posY, radius, sort);
	}

}
